package com.lanou.utp.controller;

import com.lanou.utp.entity.Clazz;
import com.lanou.utp.service.ClazzService;
import com.lanou.utp.entity.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author MaQingYun
 */

@Api("班级Controller")
@RestController
public class ClazzController {

    @Resource
    private ClazzService clazzService;

    @ApiOperation("获取年级:id, grade")
    @GetMapping("/option/grade")
    public ResponseData getGrade(){
        return this.clazzService.getGrade();
    }

    @ApiOperation("查询所有班级信息, 后台分页")
    @GetMapping("/clazzes")
    public ResponseData getClassList(Integer page) {
        return this.clazzService.getClassList(page);
    }

    @ApiOperation("班级管理页面里边, 添加班级")
    @PostMapping("/clazz")
    public ResponseData addClazz(@RequestBody Clazz clazz){
        this.clazzService.addClazz(clazz);
        return new ResponseData("ok");
    }

    @PutMapping("/clazz")
    public ResponseData updateClazz(@RequestBody Clazz clazz){
        this.clazzService.updateClazz(clazz);
        return new ResponseData("ok");
    }

    @ApiOperation("批量删除")
    @DeleteMapping("/clazzes/{list}")
    public ResponseData batchDeleteClazzes(@PathVariable List list){
        this.clazzService.batchDeleteClazzes(list);
        return new ResponseData("ok");
    }


}
